package com.y.fund.aacore.data;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import com.y.fund.utils.SQLUtil;

public class PaginationList<E> extends ArrayList<E>{

	private static final long serialVersionUID = 6948579071477348746L;

	/** 列表数据的表头标题; 在data数据与表头分离时用到 */
	private LinkedHashMap<String, String> titles;
	
	/** 默认每页分页数量 */
	public static final int PAGE_SIZE = 10;
	
	/** 当前使用的每页记录条数 */
    private int pageSize = PAGE_SIZE;

	/** 总数据条数 */
	private long totalSize = 0L;
	
    /** 当前第几页 */
	private long pageNum = 1;

	public PaginationList() {
		super();
	}
	
	public PaginationList(int pageSize, long pageNum) {
		super();
		this.pageSize = pageSize;
		this.pageNum = pageNum;
	}
	
	public void setData(List<E> data) {
		this.clear();
		this.addAll(data);
	}

	public Integer getPageSize() {
		if(pageSize<1){
			this.pageSize = PAGE_SIZE;
		}else if(pageSize > SQLUtil.MAX_QUERY_SIZE){
			this.pageSize = SQLUtil.MAX_QUERY_SIZE;
		}
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public long getPageNum() {
		return pageNum;
	}

	public void setPageNum(long pageNum) {
		this.pageNum = pageNum;
	}

	public long getTotalSize() {
		return totalSize;
	}
	public void setTotalSize(long totalSize) {
		this.totalSize = totalSize;
	}

	public LinkedHashMap<String, String> getTitles() {
		return titles;
	}

	public void setTitles(LinkedHashMap<String, String> titles) {
		this.titles = titles;
	}
	
}
